package cn.training.controller;

import java.util.List;

import jp.terasoluna.fw.dao.QueryDAO;
import jp.terasoluna.fw.dao.UpdateDAO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.training.controller.UserBean;

@Service
public class HelloWorldService {

	@Autowired
	QueryDAO queryDao;

	@Autowired
	UpdateDAO updateDao;
public UserBean searchUser(UserBean frm) {
		UserBean result = queryDao.executeForObject("User.selectUser", frm, UserBean.class);
		//frm.setUserId("test");
		//frm = queryDao.executeForObject("User.selectUser", null, UserBean.class);
		//return frm;
		return result;
	}
public UserBean searchname(UserBean nn) {
		UserBean result = queryDao.executeForObject("User.selectname", nn, UserBean.class);
		return result;
	}
public int updateUser(UserBean gg){
		return updateDao.execute("User.updatename", gg);
	}
public UserBean sUser(UserBean frm) {
	UserBean result = queryDao.executeForObject("User.sUser", frm, UserBean.class);
	return result;
}
	//插入前进行异常捕捉
public int insertUser(UserBean mm){
		int result=0;
		try{
			result=updateDao.execute("User.insertUser", mm);
		}
		catch(Exception e){
			result=999;
		}
		 return result;
	}
public UserBean rlistUser(UserBean frm) {
		UserBean param = new UserBean();
		param.setUserID(frm.getUserID());
		param.setPassword(frm.getPassword());
		UserBean re = queryDao.executeForObject("User.rlistUser", param, UserBean.class);
		return re;
	}
public List<UserBean> listUser(UserBean ls) {
		List<UserBean> result = queryDao.executeForObjectList("User.selectlistUser", ls);
		return result;
	}
public int deleteUser(UserBean de) {
		return updateDao.execute("User.deleteUser", de);
	}
public UserBean searchdUser(UserBean frm) {
	UserBean result = queryDao.executeForObject("User.searchdUser", frm, UserBean.class);
	    return result;
}

}